`

Filtering Git Log Information with Bash

Even without the pretty formatting, bash can filter git log output

with a single line:

$ git log | grep Author | grep -oP '(?<=Author: ).*' | sort -u | tr -d '<>'

This bash code runs git log, searches for any lines that start

with the word Author using grep, then pipes it to another grep

command, which uses regular expressions (-oP) to filter anything

after the word Author: and prints only the words that matched.

This filtering leaves us with the git commit authors name and email.

Because the same author could have made multiple commits, we

use sort to sort the list and to remove any duplicated lines using

the -u option, leaving us with list free of duplicated entries. Lastly,

since the email is surrounded by the characters <> by default, we

trim these characters using tr -d '<>'.

Inspecting Repository Files

The repository contains a file called app.py. Let’s quickly inspect

its contents by viewing it using a text editor. If you take a look at the

code in Listing 5-2, you’ll see that the file contains web server code

written with Pythons Flask library.

import os, subprocess

from flask import (

Flask,

send_from_directory,

send_file,

render_template,

request

)

@app.route('/')

--snip--

@app.route('/files/<path:path>')

--snip--

@app.route('/upload', methods = ['GET', 'POST'])

--snip--

@app.route('/uploads', methods=['GET'])

Black Hat Bash (Early Access) © 2023 by Dolev Farhi and Nick Aleks